class Solution:
    def partition(self, s: str) -> List[List[str]]:
        n = len(s)
        ans = []
        path = []

        def dfs(v):
            if v == n:
                ans.append(path.copy())
                return 

            for i in range(v,n):
                t = s[v:i+1]
                if t == t[::-1]:
                    path.append(t)
                    dfs(i+1)
                    path.pop()
        

        dfs(0)
        return ans